// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** download GET /api/file/${param0} */
export async function downloadUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.downloadUsingGETParams,
  options?: { [key: string]: any },
) {
  const { fileUUID: param0, ...queryParams } = params;
  return request<any>(`/api/file/${param0}`, {
    method: 'GET',
    params: { ...queryParams },
    ...(options || {}),
  });
}

/** dayNewlyAddedFile POST /api/file/day/newly/added */
export async function dayNewlyAddedFileUsingPost(options?: { [key: string]: any }) {
  return request<API.BaseResponseListDataGroupByDateDTO_>('/api/file/day/newly/added', {
    method: 'POST',
    ...(options || {}),
  });
}

/** deleteFileInfo POST /api/file/delete */
export async function deleteFileInfoUsingPost(
  body: API.DeleteRequest,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseBoolean_>('/api/file/delete', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** getFileInfoVOById GET /api/file/get/vo */
export async function getFileInfoVoByIdUsingGet(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.getFileInfoVOByIdUsingGETParams,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponseFileInfoVO_>('/api/file/get/vo', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** listFileInfoByPage POST /api/file/list/page */
export async function listFileInfoByPageUsingPost(
  body: API.FileInfoQueryRequest,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponsePageFileInfo_>('/api/file/list/page', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** listFileInfoVOByPage POST /api/file/list/page/vo */
export async function listFileInfoVoByPageUsingPost(
  body: API.FileInfoQueryRequest,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponsePageFileInfoVO_>('/api/file/list/page/vo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** listMyFileInfoVOByPage POST /api/file/my/list/page/vo */
export async function listMyFileInfoVoByPageUsingPost(
  body: API.FileInfoQueryRequest,
  options?: { [key: string]: any },
) {
  return request<API.BaseResponsePageFileInfoVO_>('/api/file/my/list/page/vo', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** upload POST /api/file/upload */
export async function uploadUsingPost(body: {}, file?: File, options?: { [key: string]: any }) {
  const formData = new FormData();

  if (file) {
    formData.append('file', file);
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele];

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''));
        } else {
          formData.append(ele, JSON.stringify(item));
        }
      } else {
        formData.append(ele, item);
      }
    }
  });

  return request<API.BaseResponseString_>('/api/file/upload', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  });
}
